<HTML>
<HEAD>
<TITLE>JavaScript Source Code 3000:  Messages:  Rainbow Text</TITLE>
<META HTTP-EQUIV="JavaScript Source Code 3000" CONTENT = "no-cache">
<META NAME="date" CONTENT="2000-09-09">
<META NAME="channel" CONTENT="Web Developer">
<META NAME="author" CONTENT="Quak Zhixuan (zhixuan@email.com)">
<META NAME="section" CONTENT="Messages">
<META NAME="description" CONTENT="Displays your text in a multitude of rainbow colors.  Definitely a visually appealing effect.  And, it's a breeze to modify.">

<SCRIPT LANGUAGE="JavaScript">
<!-- Original:  Quak Zhixuan (zhixuan@email.com) -->
<!-- Web Site:  http://www.chs.edu.sg/~991b20 -->

<!-- Modifications:  Jim Cairo (jcairo@mediaone.net) -->
<!-- Result:  Improves color selection, better results -->




<!-- Begin
function createHexArray(n) {
this.length = n;
for (var i = 1; i <= n; i++)
this[i] = i - 1;

this[11] = "A";
this[12] = "B";
this[13] = "C";
this[14] = "D";
this[15] = "E";
this[16] = "F";
return this;
}
hx = new createHexArray(16);

function convertToHex(x) {
if (x < 17) x = 16;
var high = x / 16;
var s = high+"";
s = s.substring(0, 2);
high = parseInt(s, 10);
var left = hx[high + 1];
var low = x - high * 16;
if (low < 1) low = 1;
s = low + "";
s = s.substring(0, 2);
low = parseInt(s, 10);
var right = hx[low + 1];
var string = left + "" + right;
return string;
}

function makeRainbow(text) {
text = text.substring(0, text.length);
color_d1 = 255;
mul = color_d1 / text.length;
for(var i = 0; i < text.length; i++) {
color_d1 = 255*Math.sin(i / (text.length / 3));
color_h1 = convertToHex(color_d1);
color_d2 = mul * i;
color_h2 = convertToHex(color_d2);

k = text.length;
j = k - i;
if (j < 0) j = 0;
color_d3 = mul * j;
color_h3 = convertToHex(color_d3);

document.write("<FONT COLOR=\"#" + color_h3 + color_h1 + color_h2 + "\">" + text.substring(i, i + 1) + "</FONT>");
   }
}
// End -->
</script>
</HEAD>

<BODY BGCOLOR=#ffffff vlink=#0000ff>

<BR>
<center>
<table width=600 cellpadding=0 cellspacing=10>
<tr>
<td width=468 align=center>

    
    
</td>
<td width=120 align=center>
    
</td>
</tr>
</table>
<BR>
<BR>
<basefont size=3>
<FONT SIZE="+2" FACE="Helvetica,Arial">
<A HREF="../index.htm" /" TARGET="_top"><FONT COLOR="#0000FF"><b>Home</b></font></A>
<img src="../img/arrow.gif" /img/arrow.gif" height=13 width=7 border=0 alt="}">
<A HREF="index.htm" /messages/"><font color="#FF0000"><b>Messages</b></font></A>
<img src="../img/arrow.gif" /img/arrow.gif" height=13 width=7 border=0 alt="}">
<FONT COLOR="#006666"><b>Rainbow Text</b></font></font>
<BR>
<BR>
<table BORDER=0 WIDTH=486 CELLPADDING=3 CELLSPACING=0>
<tr><td><font FACE="helvetica,arial,geneva">
<br>
<br>
<!-- Description --><!--content_start-->
Displays your text in a multitude of rainbow colors.  Definitely a visually appealing effect.  And, it's a breeze to modify.
<hr>
</td></tr>
</table>
<!-- Demonstration -->

<center>
<strong>
<font size=6>
<script>
<!--
makeRainbow("Welcome to JavaScript Source Code 3000!");
// -->
</script>
</font>
</strong>
</center>

<P>
<P>
<a name="source">
<table BORDER=0 WIDTH=486 CELLPADDING=3 CELLSPACING=0>
<tr><td BGCOLOR=yellow><font FACE="helvetica,arial,geneva"><b>JavaScript Source Code 3000:  Messages:  Rainbow Text</b>
<p>Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s).  The script is yours!!!
<br><br></font></td></tr>
<tr><td BGCOLOR=yellow ALIGN=CENTER>
<form NAME="copy">

<DIV align="center">
<input type=button value="Highlight All" onClick="javascript:this.form.txt.focus();this.form.txt.select();">&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT TYPE="text" NAME="total" VALUE="Script Size:  1.69 KB" size=24>
</DIV>

<textarea NAME="txt" ROWS=20 COLS=75 WRAP=VIRTUAL>

&lt;!-- TWO STEPS TO INSTALL RAINBOW TEXT:

  1.  Copy the coding into the HEAD of your HTML document
  2.  Add the last code into the BODY of your HTML document  --&gt;

&lt;!-- STEP ONE: Paste this code into the HEAD of your HTML document  --&gt;

&lt;HEAD&gt;

&lt;SCRIPT LANGUAGE="JavaScript"&gt;
&lt;!-- Original:  Quak Zhixuan (zhixuan@email.com) --&gt;
&lt;!-- Web Site:  http://www.chs.edu.sg/~991b20 --&gt;

&lt;!-- Modifications:  Jim Cairo (jcairo@mediaone.net) --&gt;
&lt;!-- Result:  Improves color selection, better results --&gt;

&lt;! &gt;
&lt;! &gt;

&lt;!-- Begin
function createHexArray(n) {
this.length = n;
for (var i = 1; i &lt;= n; i++)
this[i] = i - 1;

this[11] = "A";
this[12] = "B";
this[13] = "C";
this[14] = "D";
this[15] = "E";
this[16] = "F";
return this;
}
hx = new createHexArray(16);

function convertToHex(x) {
if (x &lt; 17) x = 16;
var high = x / 16;
var s = high+"";
s = s.substring(0, 2);
high = parseInt(s, 10);
var left = hx[high + 1];
var low = x - high * 16;
if (low &lt; 1) low = 1;
s = low + "";
s = s.substring(0, 2);
low = parseInt(s, 10);
var right = hx[low + 1];
var string = left + "" + right;
return string;
}

function makeRainbow(text) {
text = text.substring(0, text.length);
color_d1 = 255;
mul = color_d1 / text.length;
for(var i = 0; i &lt; text.length; i++) {
color_d1 = 255*Math.sin(i / (text.length / 3));
color_h1 = convertToHex(color_d1);
color_d2 = mul * i;
color_h2 = convertToHex(color_d2);

k = text.length;
j = k - i;
if (j &lt; 0) j = 0;
color_d3 = mul * j;
color_h3 = convertToHex(color_d3);

document.write("&lt;FONT COLOR=\"#" + color_h3 + color_h1 + color_h2 + "\"&gt;" + text.substring(i, i + 1) + "&lt;/FONT&gt;");
   }
}
// End --&gt;
&lt;/script&gt;
&lt;/HEAD&gt;

&lt;!-- STEP TWO: Copy this code into the BODY of your HTML document  --&gt;

&lt;BODY&gt;

&lt;center&gt;
&lt;strong&gt;
&lt;font size=6&gt;
&lt;script&gt;
&lt;!--
makeRainbow("Welcome to JavaScript Source Code 3000!");
// --&gt;
&lt;/script&gt;
&lt;/font&gt;
&lt;/strong&gt;
&lt;/center&gt;

 

&lt;!-- Script Size:  1.69 KB --&gt;</textarea><br><font FACE="helvetica,arial,geneva"></font></td></tr>

</table>
</form>
</FONT>
</CENTER>


</center>
</body></html>